package cn.unknowpupil.controller.system;

import cn.unknowpupil.common.core.annotation.RepeatSubmit;
import cn.unknowpupil.common.security.dto.LoginUser;
import cn.unknowpupil.common.security.utils.SecurityUtils;
import cn.unknowpupil.common.redis.utils.RedisUtil;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Date;

/**
 * Created at 2020/10/19 by w10g <br>
 * Initialize RedisController ... <br>
 *
 * @author unknowpupil
 * @since 0.0.1
 */
@Api(tags = {"系统-测试redis" }, value = "redis")
@Slf4j
@RequestMapping("admin/redis")
@RestController
@RequiredArgsConstructor
public class RedisController {
    /**@ redis中存储的过期时间60s*/
    private static int ExpireTime = 60;

    private final RedisUtil redisUtil;



    @RepeatSubmit
    @GetMapping("get")
    public Object redisget(String key){
        return  redisUtil.get(key);
    }

    @PutMapping("expire")
    public boolean expire(String key){
        return redisUtil.expire(key,ExpireTime);
    }
}
